home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Source / E / Screens / OpenScreen.e < prev    next >
Encoding:
Text File  |  1998-05-06  |  2.6 KB  |  87 lines

  1. /* GMS-example
  2.  * Name:    OpenScreen.e
  3.  * Type:    Example on screen and blitter module
  4.  * Version: 1.1
  5.  * Author:  G. W. Thomassen (0000272e@lts.mil.no)
  6.  */
  7.  
  8. MODULE 'gms/dpkernel','gms/dpkernel/dpkernel','gms/graphics/pictures',
  9.        'gms/screens','gms/system/register','gms/system/modules','gms/graphics/pictures',
  10.        'gms/graphics/screens','gms/graphics/blitter','gms/blitter'
  11.  
  12. ENUM NONE,ERR_LIB,ERR_SCR,ERR_SMOD,ERR_BMOD
  13.  
  14. PROC main() HANDLE -> Better use exceptions!
  15.   DEF scr=NIL:PTR TO screen,
  16.       scrmodule=NIL:PTR TO module,
  17.       bltmodule=NIL:PTR TO module,
  18.       fstate=NIL:LONG,
  19.       ms=FALSE
  20.  
  21.   -> Open the library
  22.   IF (dpkbase:=OpenLibrary('GMS:libs/dpkernel.library',0))=NIL THEN Raise(ERR_LIB)
  23.  
  24.   -> Initialize the use of the blitter-module
  25.   IF (bltmodule:=Init([TAGS_MODULE,NIL,     ->blitter-module
  26.       MODA_NUMBER,    MOD_BLITTER,
  27.       MODA_TABLETYPE, JMP_AMIGAE,
  28.       TAGEND], NIL))=NIL THEN Raise(ERR_BMOD)
  29.       bltbase := bltmodule.modbase
  30.  
  31.   -> Initialize the use of the screen-module
  32.   IF (scrmodule:=Init([TAGS_MODULE,NIL,
  33.       MODA_NUMBER,    MOD_SCREENS,
  34.       MODA_TABLETYPE, JMP_AMIGAE,
  35.       TAGEND], NIL))=NIL THEN Raise(ERR_SMOD)
  36.  
  37.     scrbase:=scrmodule.modbase
  38.  
  39.  
  40.   -> Set up a screen..
  41.   IF (scr := Init([TAGS_SCREEN,NIL,
  42.       GSA_Attrib,  SCR_CENTRE,
  43.       GSA_ScrMode, SM_HIRES OR SM_LACED,
  44.       GSA_Width,   640,
  45.       GSA_Height,  512,
  46.         GSA_BitmapTags, NIL,
  47.         BMA_Planes, 3,
  48.         BMA_Palette, [PALETTE_ARRAY,6,$000000,$ffffff,$ffff00,$ff0000,$ff00ff,$0000ff],
  49.         TAGEND, NIL,
  50.       TAGEND], NIL))=NIL THEN Raise(ERR_SCR)
  51.  
  52.   Show(scr)     -> Open the screen!
  53.  
  54.   -> Main loop!
  55.   LOOP
  56.     WaitAVBL() -> Wait one vertical blank
  57.  
  58.     -> Do something stupid (only to use blitter-module)
  59.     DrawLine(scr.bitmap,Rnd(scr.width),Rnd(scr.height),Rnd(scr.width),Rnd(scr.width),Rnd(4)+1)
  60.  
  61.     -> Fade to white
  62.     IF ms=TRUE
  63.       fstate:=PaletteToColour(scr,fstate,1,0,scr.bitmap.amtcolours,scr.bitmap.palette+8,$ffffff)
  64.       WaitAVBL()   -> Slow down the fade even more
  65.       IF fstate != NIL THEN JUMP exit0  -> Check if $ffffff is reached, and exit the loop
  66.     ELSEIF Mouse()=1
  67.       ms:=TRUE
  68.     ENDIF
  69.   ENDLOOP
  70.   exit0:
  71.  
  72.   ->Quit with no error..
  73.   Raise(NONE)
  74. EXCEPT DO
  75.   IF scr THEN Free(scr)
  76.   IF scrmodule THEN Free(scrmodule)
  77.   IF bltmodule THEN Free(bltmodule)
  78.   CloseDPK()
  79.   SELECT exception
  80.   CASE ERR_LIB; WriteF('Couldn\at open "dpkernel.library"\n')
  81.   CASE ERR_SMOD; WriteF('Couldn\at initialize screen-module\n')
  82.   CASE ERR_SCR; WriteF('Couldn\at open screen\n')
  83.   CASE ERR_BMOD; WriteF('Couldn\at initialize blitter-module\n')
  84.   ENDSELECT
  85.   CleanUp(0)
  86. ENDPROC
  87.